import impl.GoToSchoolByBus;
import service.GoToSchoolStrategy;

/**
 * 定义去上学这个任务
 * 针对这个任务 我们来选择不同的策略 从而达到目的
 */
public class GoToSchool {
    private GoToSchoolStrategy strategy;

    public void setStrategy(GoToSchoolStrategy strategy){
        this.strategy = strategy;
    }

    public GoToSchoolStrategy getStrategy(GoToSchoolStrategy strategy){
        return strategy;
    }

    //调用所选择的策略的实现方法
    public void strategyMethod(){
        strategy.strategyMethod();
    }

    public static void main(String[] args) {
        GoToSchool goToSchool = new GoToSchool();
        GoToSchoolStrategy strategy = new GoToSchoolByBus();

        goToSchool.setStrategy(strategy);
        goToSchool.strategyMethod();
    }
}
